import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../utils/utils_logger.dart';
import '../../../../widgets/detail_item_widget/detail_item_view.dart';
import '../../../../widgets/globel_widget.dart';
import '../../../../widgets/spirit/spirit_view.dart';

class cuPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: [
          const Center(child: Text('Group1')),
          IconButton(
              icon: const Icon(Icons.add),
              tooltip: "添加分组",
              onPressed: () {
                print("Search Pressed");
              }),
        ],
      ),
      body: Container(
        child: SingleChildScrollView(
          child: Column(
            children: [

              spaceHeight(),
              SpiritComponent(onTap: () {
                logd('onTap');
              },onLongPress: () {
                logd('onLongPress');
              },
                lLeftText: 'MS-L1', lRightText: '18/F',
                rLeftText: 'AL', rCenterText: 'PW',
                rLeftColor: Colors.red, rCenterColor: Colors.orange,),
              spaceHeight(),
              Container(
                padding: const EdgeInsets.symmetric(horizontal: 12),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('detailConsName'.tr),
                    spaceWidth(),
                    Expanded(
                      flex: 1,
                      child: TextField(
                        decoration: InputDecoration(label: Text('香港广东道1000号 广西大厦')),
                      ),
                    ),
                    ElevatedButton(onPressed: () {}, child: Text('detailMap'.tr)),
                  ],
                ),
              ),
              spaceHeight(),
              line(),
              commonPart(leftLabel: 'breakdownTime', rightLabel: 'breakdownCode', leftValue: '2023/06/28 12：23', rightValue: '010，007'),
              spaceHeight(),
              line(),
              commonPart(leftLabel: 'acceptTime', rightLabel: 'engineer', leftValue: '2023/06/28 12：23', rightValue: '010，007'),
              spaceHeight(),
              line(),
              commonPart(leftLabel: 'acceptTime', rightLabel: 'engineer', leftValue: '2023/06/28 12：23', rightValue: '010，007'),
              spaceHeight(),
              line(),
              commonPart(leftLabel: 'recoverTime', rightLabel: 'engineer', leftValue: '2023/06/28 12：23', rightValue: '010，007'),
              spaceHeight(),
              line(),
              actionPart(),
              spaceHeight(),
              line(),
              inputPart(),
              spaceHeight(),
              line(),
              Text('故障处理指导：'),
              Container(
                padding: EdgeInsets.all(12),
                margin: EdgeInsets.symmetric(horizontal: 12),
                color: Colors.grey,
                child: TextField(
                  decoration: InputDecoration(label: Text('''gdgdgdfgdgdgdgdfgdfgdf
                  dfasfasffasffas'''), border: InputBorder.none),
                ),
              ),
              spaceHeight(),
              line(),
              spaceHeight(height: 60),
            ],
          ),
        ),
      ),
    );
  }

  Widget line() {
    return Container(
      height: 0.5,
      color: Colors.grey,
      width: Get.width,
    );
  }

  Widget commonPart({required String leftLabel, required String rightLabel, String leftValue = '', String rightValue = ''}) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 12),
      height: 60,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          // Text('breakdownTime'.tr),
          Text(leftLabel.tr),
          spaceWidth(),
          Container(
            color: Colors.grey,
            height: 45,
            child: Center(child: Text(leftValue)),
            // child: Text('2023/06/28 12：23'),

          ),
          Text(rightLabel.tr),
          Container(
            // child: Text('010，007'),
            color: Colors.grey,
            height: 45,
            child: Center(child: Text(rightValue)),

          ),
        ],
      ),
    );
  }

  Widget  actionPart() {
    return Container(
      color: const Color(0x50757575),
      padding: const EdgeInsets.symmetric(horizontal: 12),
      height: 60,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          // Text('breakdownTime'.tr),
          Text('leftLabel'.tr),
          spaceWidth(),
          ElevatedButton(onPressed: () {}, child: Text('受理确认')),
          spaceWidth(),
          ElevatedButton(onPressed: () {}, child: Text('恢复确认'))
        ],
      ),
    );
  }

  Widget inputPart() {
    return Container(
      height: 55,
      color: const Color(0x50757575),
      padding: const EdgeInsets.symmetric(horizontal: 12),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text('operator'.tr),
          spaceWidth(),
          Expanded(
            flex: 1,
            child: Container(
              color: Colors.white,
              height: 45,
              child: TextField(
                decoration: InputDecoration(label: Text('A22，B12'), border: InputBorder.none, ),
              ),
            ),
          ),
          spaceWidth(width: 12),
          ElevatedButton(onPressed: () {}, child: Text('Send'.tr)),
          spaceWidth(),
          Checkbox(value: false, onChanged: (val) {}),
          Text('AUTO')
        ],
      ),
    );
  }

}
